﻿using System;
using System.Drawing;
using System.Linq;
using Autodesk.Revit.DB;

namespace YJKCopyModel.GeothermalPipeQuickModel
{
	public static class ColorSet
	{
		public static System.Drawing.Color GetXmlDataColor(string rgb)
		{
			System.Drawing.Color result = default(System.Drawing.Color);
			try
			{
				bool flag = rgb != "默认";
				if (flag)
				{
					result = System.Drawing.Color.FromArgb(int.Parse(rgb.Split(new char[]
					{
						' '
					}).ElementAt(1)), int.Parse(rgb.Split(new char[]
					{
						' '
					}).ElementAt(2)), int.Parse(rgb.Split(new char[]
					{
						' '
					}).ElementAt(3)));
				}
			}
			catch (ArgumentOutOfRangeException ex)
			{
				result = System.Drawing.Color.FromArgb(128, 128, 128);
			}
			return result;
		}

		public static int GetIntAboutColor(System.Drawing.Color color)
		{
			return (int)color.B << 16 | (int)((ushort)((int)color.G << 8 | (int)color.R));
		}

		public static string getNewRGB(byte R)
		{
			string result = "";
			bool flag = R <= 9;
			if (flag)
			{
				result = "00" + R;
			}
			else
			{
				bool flag2 = R <= 99 && R >= 10;
				if (flag2)
				{
					result = "0" + R;
				}
			}
			bool flag3 = R >= 100;
			if (flag3)
			{
				result = R.ToString();
			}
			return result;
		}

        public static Autodesk.Revit.DB.Color GetLineColor(System.Drawing.Color color)
		{
			return new Autodesk.Revit.DB.Color(color.R, color.G, color.B);
		}
	}
}
